package xian.woniuxy.be.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xian.woniuxy.be.dao.CustomerMapper;
import xian.woniuxy.be.dao.custom.CustomCustomerMapper;
import xian.woniuxy.be.entity.Customer;
import xian.woniuxy.be.service.ICustomerService;

import java.util.List;

/**
 * @author Gong
 * @time 2022/01/05 14:57:39
 */
@Service
@Transactional
public class CustomerServiceImpl implements ICustomerService {

    @Autowired
    private CustomCustomerMapper customerMapper;

    @Override
    public void save(Customer customer) {
        customerMapper.insert(customer);
    }

    @Override
    public void delete(int cusId) {
        customerMapper.deleteByPrimaryKey(cusId);
    }

    @Override
    public void update(Customer customer) {
        customerMapper.updateByPrimaryKey(customer);
    }

    @Override
    public List<Customer> findAll() {
        List<Customer> list = customerMapper.selectAll();
        return list;
    }

    @Override
    public Customer findOne(int cusId) {
        Customer customer = customerMapper.selectOne(cusId);
        return customer;
    }

    @Override
    public List<Customer> selectFromname(String theName) {
        List<Customer> list = customerMapper.selectFromname(theName);
        return list;
    }
}
